<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\CustomMenu as CustomMenumodel;
return new class extends Migration {
    /**
     * 自定义菜单
     * 
     */
    public function up(): void
    {
        Schema::create('CustomMenu', function (Blueprint $table) {
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->id();
            $table->string('MenuName', 100);
            $table->text('datatext');
            $table->string('userid', 50)->nullable();
            $table->string('roleid', 50)->nullable();
            $table->string('des', 200)->nullable();
            $table->integer('state')->nullable()->default(1);
            $table->string('tabnm', 50)->nullable();
            $table->string('modifier', 50)->nullable();
            $table->integer('isdel')->nullable()->default(0);
            $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
            $table->timestamp('created_at')->nullable();
        });
        // 插入默认数据
        CustomMenumodel::create([
            'MenuName' => '系统默认菜单',
            'des' => '系统默认菜单不可修改删除',
            'state' => 1,
            'tabnm' => '系统管理员',
            'datatext' => '',
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('CustomMenu');
    }
};
